//
// Created by 123 on 2024/3/6.
//
#include <iostream>

using namespace std;
typedef struct LinkNode{
    char data;
    LinkNode *next;

}LinkNode,*LinkStack;
//初始化
LinkStack init_CharStack();
//判空栈
bool isEmpty(LinkStack l);
//进栈
bool push(LinkStack &l,char e);
//出栈
char pop(LinkStack &l);
//读取栈顶元素
char getTop(LinkStack l);




void show(LinkStack l);



LinkStack init_CharStack(){
    LinkStack  l=(LinkNode *) malloc(sizeof(LinkNode));
    l->next=NULL;
    return l;
}
bool isEmpty(LinkStack l){
    return l->next==NULL;
}
bool push(LinkStack &l,char e){
    LinkNode *node= (LinkNode *)malloc(sizeof(LinkNode));
    node->data=e;
    node->next=l->next;
    l->next=node;
    return true;
}
char pop(LinkStack &l){
    if(l->next==NULL)
        return false;
    char e=l->next->data;
    LinkNode *n=l->next;
    l->next=l->next->next;
    free(n);
    return e;
}
char getTop(LinkStack l){
    if(l->next==NULL)
        return false;

    return l->next->data;
}
void show(LinkStack l){
    while (l->next!=NULL){
        l=l->next;
        cout<<l->data<<"    ";
    }
    cout<<endl;
}